<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use DB;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('home');
    }

    public function serve_details($sid){

        dd($sid);exit;
    }


    public function app(){

        DB::table('bnnaers')->insert([
                                    ['path'=>'/uploads/images/banner/201811/14/1542200494_dU9NvVUwVg.jpg','href'=>'http://shopapp.monanxiao.com','commit'=>'
                                    轮播图1'],
                                    ['path'=>'/uploads/images/banner/201811/14/1542200494_dU9NvVUwVg.jpg','href'=>'http://shopapp.monanxiao.com','commit'=>'
                                    轮播图2'],
                                    ['path'=>'/uploads/images/banner/201811/14/1542200494_dU9NvVUwVg.jpg','href'=>'http://shopapp.monanxiao.com','commit'=>'
                                    轮播图3'],
                                ]);

    }

    //搜索用户
    public function userlist(Request $request){

        if($request->type == 'name')
        {


               $user = DB::table('users')
                            ->where([
                                        ['phone','!=','null'],
                                        ['vip','=',$request->vip],
                                        ['status',$request->ustatus],
                                        ['name','like','%' . $request->index . '%'],
                                    ])->get();

        }elseif($request->type == 'mobile')
        {
            $user = DB::table('users')
                            ->where([
                                        ['phone','!=','null'],
                                        ['vip','=',$request->vip],
                                        ['status',$request->ustatus],
                                        ['phone','like','%' . $request->index . '%'],
                                    ])->get();

        }
               
        return view('user.userlist',compact('user'));
    }
}
